package com.yvon.service.demo.jdk.future;

import cn.hutool.core.convert.Convert;
import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 * @author : Yvon
 * @since : 2021-10-20
 */
@Slf4j
public class UserService {

    /**
     * 烧水
     *
     * @return long
     * @author : Yvon / 2021-10-20
     */
    public String hotWater() {
        try {
            log.info("烧水：休眠5秒");
            Thread.sleep(5000);
            log.info("烧水：起来干活");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程：  " + Thread.currentThread().getName());
        return "100°的蒸馏水烧好了";
    }

    /**
     * 洗茶杯
     *
     * @return long
     * @author : Yvon / 2021-10-20
     */
    public String cleanCaps() {
        try {
            log.info("洗茶杯：休眠5秒");
            Thread.sleep(5000);
            log.info("洗茶杯：起来干活");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程：  " + Thread.currentThread().getName());
        return "景德镇的茶杯洗好了";
    }


    /**
     * 买茶叶
     *
     * @return String
     * @author : Yvon / 2021-10-20
     */
    public String buyTeaLeaf() {
        try {
            log.info("买茶叶：休眠5秒");
            Thread.sleep(5000);
            log.info("买茶叶：起来干活");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程：  " + Thread.currentThread().getName());
        return "龙井茶叶买好了";
    }



    public String getName(Integer id) {
        try {
            log.info("取名字：休眠5秒");
            Thread.sleep(5000);
            log.info("取名字：起来干活");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程：  " + Thread.currentThread().getName());

        return "阿"+  Convert.numberToChinese(id, true);
    }

    public Integer getRate(String name) {
        try {
            log.info("取价格：休眠5秒");
            Thread.sleep(5000);
            log.info("取价格：起来干活");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("当前线程：  " + Thread.currentThread().getName());
        Random random = new Random();
        return random.nextInt();
    }
}
